<template>
	<ui-sys :title="areaName">
		<view class="questionListBox" v-if="dataList.length !== 0">
			<view class="item" v-for="question in dataList" :key="question.qid"
				@click="handleQuestionDetail(question.qid)">
				<!-- 背景卡片 -->
				<view class="topCard">
					<!-- 标题 -->
					<view class="title">
						{{ question.title  }}
					</view>
					<!-- 个人信息 -->
					<view class="user" @click.stop="handlePublishUser(question.simpleUserVO.uid)">
						<image :src="question.simpleUserVO.avatarUrl" class="headPicture" mode=""></image>
						<view class="uerContent">
							<view class="nickName">{{
			           question.simpleUserVO.nickName
			         }}</view>
					 <!--  v-if="question.simpleUserVO.authentication" -->
							<view class="authentication">官方认证出题人</view>
						</view>
					</view>
				</view>
				<!-- 详情 -->
				<view class="detail">
					<view class="title">
						问题描述<image class="quote" src="../../static/question/quote.png" mode=""></image>
					</view>
					<view class="content">
						{{ question.des === ""? "暂无题目介绍":question.des }}
					</view>
				</view>
			</view>
		</view>

	</ui-sys>
</template>

<script>
	import {
		questionsByClaaRequest
	} from '@/api/question.js';
	export default {
		data() {
			return {
				areaName: '',
				areaID: '',
				dataList: []

			};
		},
		onLoad: function(params) { //option为object类型，会序列化上个页面传递的参数


			this.areaID = params.areaID;
			// 动态设置标题
			this.areaName = decodeURIComponent(params.areaName);

			// 获取列表 
			let data = {
				cid: this.areaID
			}
			let param = {
				page_num: 1,
				page_size:100
			}
			questionsByClaaRequest(param, data).then(res => {
				if (res.code != 200) {
					this.$Tips('发送失败请稍后重试');
					return
				}
				console.log(res.data)
				this.dataList = res.data
			})
		},

		methods: {
			// 进入个人中心
			handlePublishUser(_id) {
				uni.navigateTo({
					url: `/pages/my/info?userID=${_id}`,
				});
			},
			// 进入题目解答列表
			handleQuestionDetail(_id) {
				uni.navigateTo({
					url: `/pages/question/detail?id=${_id}`,
				});
			}
		}
	}
</script>

<style lang="scss">
	@import "../../utils/common.scss";

	.questionListBox {
		.item {
			position: relative;
			width: 672rpx;
			height: 608rpx;
			background-color: #fff;
			box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.1);
			border-radius: 20rpx;
			margin: 0 auto;
			margin-top: 66rpx;

			&:nth-child(odd) {
				.topCard {
					background: url(../../static/question/questionWriteBackrgound.png) no-repeat center / 100%;
				}
			}

			&:nth-child(even) {
				.topCard {
					background: url(../../static/question/questionBookBackrgound.png) no-repeat center / 100%;
				}
			}

			.topCard {
				width: 100%;
				height: 320rpx;
				overflow: hidden;

				.title {
					width: 616rpx;
					height: 100rpx;
					margin: 40rpx auto 36rpx auto;
					color: #2b2b66;
					font-size: 36rpx;
					font-weight: bold;
					line-height: 50rpx;
					@include text-ellipsis(2);
				}

				.user {
					display: flex;
					justify-content: flex-start;
					align-items: center;
					margin-left: 32rpx;

					.headPicture {
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
					}

					.uerContent {
						margin-left: 24rpx;

						.nickName {
							max-width: 400rpx;
							@include text-ellipsis;
							font-size: 28rpx;
							color: #5454a1;
						}

						.authentication {
							font-size: 20rpx;
							color: #ffac61;
						}
					}
				}
			}

			.detail {
				width: 612rpx;
				margin: 0 auto;
				margin-top: 14rpx;

				.title {
					display: flex;
					justify-content: flex-start;
					align-items: flex-start;
					font-size: 28rpx;
					font-weight: bold;
					color: #446eea;

					.quote {
						width: 34rpx;
						height: 24rpx;
						margin-left: 10rpx;
					}
				}

				.content {
					min-height: 100rpx;
					color: #666666;
					font-size: 24rpx;
					margin-top: 20rpx;
					line-height: 34rpx;
					letter-spacing: 2rpx;
					@include text-ellipsis(3);
				}

			}

			&:first-child {
				margin-top: 20rpx;
			}
		}
	}
</style>
